/*
 * @Description: 前台授权用户
 * @Author: zheng yiliang
 * @Date: 2021-05-16 18:50:52
 * @LastEditTime: 2021-05-25 21:52:42
 * @LastEditors: zheng yiliang
 */
/*
 * @Description: 评论模型
 * @Author: zheng yiliang
 * @Date: 2021-04-13 20:58:34
 * @LastEditTime: 2021-05-16 18:49:48
 * @LastEditors: zheng yiliang
 */

const mongoose = require('../core/mongodb')
const { Schema, model } = mongoose
const autoIncrement = require('mongoose-auto-increment-fix');

// 前台用户模型
const webUserSchema = new Schema({
  // 父评论的用户信息
  user_id: { type: String, required: true, unique: true },

  // 名字
  name: { type: String, required: true, default: '' },

  // 用户类型 0：博主 1：其他用户
  type: { type: Number, default: 1 },

  // 头像
  avatar: { type: String, default: 'user' },
  address: {
    province: { type: String },
    city: { type: String }
  },
  year: { type: String }, // 年龄
  // 创建日期
  create_time: { type: Date, default: Date.now },

  update_time: { type: Date, default: Date.now },
});

// 自增 ID 插件配置
webUserSchema.plugin(autoIncrement.plugin, {
  model: 'WebUser',
  field: 'id',
  startAt: 1,
  incrementBy: 1,
});

// 标签模型
module.exports = model('WebUser', webUserSchema);
